Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
The getos npm package is used to detect the operating system of the environment in which a Node.js application is running. It provides a simple API to retrieve detailed information about the OS, including the distribution name and version for Linux systems.
Detect Operating System
This feature allows you to detect the operating system of the environment. The callback function returns an object containing details about the OS, such as the distribution name and version for Linux systems.
const getos = require('getos');
getos((e, os) => {
if (e) return console.log(e);
console.log(os);
});
Detect Linux Distribution
This feature is specifically useful for detecting the Linux distribution and its version. The callback function checks if the OS is Linux and then logs the distribution name and version.
const getos = require('getos');
getos((e, os) => {
if (e) return console.log(e);
if (os.os === 'linux') {
console.log(`You are running ${os.dist} version ${os.release}`);
}
});
The 'os' module is a built-in Node.js module that provides operating system-related utility methods and properties. Unlike getos, it does not provide detailed information about Linux distributions but offers a broader range of OS-related functionalities.
The 'systeminformation' package provides detailed system and hardware information. It offers more comprehensive data compared to getos, including CPU, memory, and network details, but may be overkill if you only need OS detection.
The 'node-os-utils' package provides a set of utilities to get information about the operating system, including CPU, memory, and disk usage. It offers more extensive system monitoring capabilities compared to getos.
Get the OS/Distribution name of the environment you are working on
os.platform()
returns linux
. If you want the distrubtion name, you're out of luck.
This. Simply call:
var getos = require('getos')
getos(function(e,os) {
if(e) return console.log(e)
console.log("Your OS is:" +JSON.stringify(os))
})
The os
object conforms to:
{
os: [OS NAME],
dist:[DIST NAME],
codename:[CODENAME],
release:[VERSION]
}
For example:
{
os: "linux",
dist: "Ubuntu",
codename: "precise",
release: "12.04"
}
Check os.json
in this repo. Any distribution that shares a common resource file with another distrubtion is currently untested. These are the arrays of distrubitons with more than 1 member. If you are using one of these distrubtions, please submit an issue letting me know if it works. If it fails, please post the content of the file.
If you have a distrubtion not in os.json
, please identify your resource file and submit it's name and content along with your distrbution/version in an issue.
Thanks for helping make this tool great.
Unit tests stub out the behaviour of the OS files and libraries we depend on to ensure the behaviour of the application is sound. You can run these simply by running npm test
getos has been made possible by these fantastic contributors:
Benjamin E. Coe | GitHub/bcoe | Twitter/@benjamincoe |
---|---|---|
Eugene Sharygin | GitHub/eush77 | Twitter/@eush77 |
David Routhieau | GitHub/root-io | unknown |
Lawrence | GitHub/mindmelting | Twitter/@mindmelting |
Roman Jurkov | GitHub/winfinit | Twitter/@winfinit |
Rod Vagg | GitHub/rvagg | Twitter/@rvagg |
Zeke Sikelianos | GitHub/zeke | Twitter/@zeke |
Alexander | GitHub/alex4Zero | Twitter/@alex4Zero |
FAQs
Get the OS/Distribution name of the environment you are working on
We found that getos demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.